<?php

namespace App\Policies\Admin;

use App\Models\User;
use App\Models\Role;
use App\Models\TestList;
use Illuminate\Auth\Access\HandlesAuthorization;

class TestListPolicy
{
    use HandlesAuthorization;

    public function before()
    {
        return auth()->user()->hasRole(Role::SUPER_ADMIN);
    }

    public function create(User $user)
    {
        return $user->hasAnyPermission(['testList.store']);
    }

    public function update(User $user, TestList $testList)
    {
        return $user->id === $testList->user_id || $user->hasAnyPermission(['testList.update']);
    }

    public function delete(User $user, TestList $testList)
    {
        return $user->id === $testList->user_id || $user->hasAnyPermission(['testList.destroy']);
    }
}
